import { reqSearchInfo } from '@/api'
export default {
  state: {
    goodsInfo: {},
  },
  mutations: {
    UPDATE_GOODSINFO(state, goodsInfo) {
      state.goodsInfo = goodsInfo
    },
  },
  actions: {
    async getGoodsInfo({ commit }, searchParams) {
      let result = await reqSearchInfo(searchParams)
      if (result.code === 200) {
        commit('UPDATE_GOODSINFO', result.data)
      }
    },
  },
  getters: {
    goodsList(state) {
      return state.goodsInfo.goodsList || []
    },
    trademarkList(state) {
      return state.goodsInfo.trademarkList || []
    },
    attrsList(state) {
      return state.goodsInfo.attrsList || []
    },
    pageNo(state) {
      return state.goodsInfo.pageNo
    },
    pageSize(state) {
      return state.goodsInfo.pageSize
    },
    total(state) {
      return state.goodsInfo.total
    },
  },
}
